function parents = select( method, population, count, generation )
    global nForElite maxTemperature minTemperature decRateBoltz;

    switch (method)
        case 1  % ROULETTE
            totalFitness = sum(population.fitness);
            relativeFitness = population.fitness./totalFitness;

            for i = 2:length(population.individuals)
                relativeFitness(i)=relativeFitness(i)+relativeFitness(i-1);
            end

            for i = 1 : count
                aux = rand();
                index = length(find(aux>relativeFitness))+1;
                parents.individuals{i} = population.individuals{index};
                parents.fitness(i) = population.fitness(index);
            end

        case 2  % ELITE
            for i = 1 : count
                [value index] = max(population.fitness);
                parents.individuals{i} = population.individuals{index};
                parents.fitness(i) = population.fitness(index);
                population.fitness(index) = 0.0;
            end
        case 3 % ELITE + ROULETTE
            parentsElite = select(2,population,nForElite);
            parentsRoulette = select(1,population,count-nForElite);
            
            parents.individuals = [parentsElite.individuals parentsRoulette.individuals];
            parents.fitness = [parentsElite.fitness parentsRoulette.fitness];
        case 4 % UNIVERSAL
            totalFitness = sum(population.fitness);
            relativeFitness = population.fitness./totalFitness;

            for i = 2:length(population.individuals)
                relativeFitness(i)=relativeFitness(i)+relativeFitness(i-1);
            end
            
            interval = 1/count;
            aux = rand()-interval;
            for i = 1 : count
                aux = aux + interval;
                if aux>1
                    aux=aux-1;
                end
                index = length(find(aux>relativeFitness))+1;
                parents.individuals{i} = population.individuals{index};
                parents.fitness(i) = population.fitness(index);
            end

        case 5 % BOLTZMAN
            temperature = maxTemperature - generation * decRateBoltz;
            if temperature < minTemperature
                temperature = minTemperature;
            end
            
            avgTime = mean(exp(population.fitness./temperature));
            relativeSlot = exp(population.fitness./temperature)./avgTime;

            for i = 2:length(population.individuals)
                relativeSlot(i)=relativeSlot(i)+relativeSlot(i-1);
            end
            
            for i = 1 : count
                aux = rand() * relativeSlot(end);
                index = length(find(aux>relativeSlot))+1;
                parents.individuals{i} = population.individuals{index};
                parents.fitness(i) = population.fitness(index);
            end
            
        case 6 % ELITE + BOLTZMAN
            parentsElite = select(2,population,nForElite);
            parentsBoltzman = select(5,population,count-nForElite);
            
            parents.individuals = [parentsElite.individuals parentsBoltzman.individuals];
            parents.fitness = [parentsElite.fitness parentsBoltzman.fitness];
           
        otherwise
            disp('error in select type');
    end
end

